//
//  Auction_MainColumn_TbvCell_WX.m
//  ZITHER
//
//  Created by weixin on 2019/5/31.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "Auction_MainColumn_TbvCell_WX.h"

@implementation Auction_MainColumn_TbvCell_WX

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setUI];
    self.backgroundColor = HexColor(0xeeeeee);

}


-(void)setModelSub:(specialSaleStatusSubModel *)modelSub{
    _modelSub = modelSub;
    
    [self.Pic sd_setImage:modelSub.cover];
    self.TitleLab.text = modelSub.name;
    self.timeRemainingLab.text = @"剩余时间";
    
    if ([modelSub.secondHand isEqualToString:@"true"]) {
        self.TitleSubLab.text = @"二手";
        self.TitleSubLab.backgroundColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:0.5];

    }else{
        self.TitleSubLab.text = @"全新";
        self.TitleSubLab.backgroundColor = [UIColor colorWithRed:255/255.0 green:111/255.0 blue:111/255.0 alpha:0.5];

    }

//    self.timeRemainingLab.text = modelSub.subtitle;
    
//    if ([modelSub.annotation.remainingTime isEqualToString:@"0"]) {
//        self.TitleSubLab.textColor = HexColor(0x999999);
//        self.TitleSubLab.text = @"暂无专场，请稍后";
//    }else{
//        self.TitleSubLab.textColor = HexColor(0xff6f6f);
//        self.TitleSubLab.text = @"下一场开卖时间";
//    }
    
    if (modelSub.annotation.goods.count>0) {
        self.scr.hidden = NO;
        NSMutableArray *arrM = [[NSMutableArray alloc]init];
        for (specialSaleSceneidGoodS *model  in modelSub.annotation.goods) {
            [arrM addObject:model.cover];
        }
        [self.scr addScrImage:arrM imageHeight:100];
        [self.scr mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.Pic.mas_bottom).offset(10);
            make.height.mas_equalTo(100);
        }];
    }else{
        self.scr.hidden = YES;
        [self.scr mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.Pic.mas_bottom).offset(0);
            make.height.mas_equalTo(0);
        }];
    }


}

-(void)setUI{
    /**
     TitleLab
     TitleSubLab
     timeRemainingLab
     scr
     */
    
    [self.Pic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.height.mas_equalTo((kScreenW-30)/346.0*126);
        make.top.equalTo(self).offset(40);
    }];
    
    [self.TitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.Pic).offset(15);
        make.top.equalTo(self.Pic).offset(30);
        make.height.mas_equalTo(20);
    }];
    
    [self.TitleSubLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.TitleLab).offset(0);
        make.left.equalTo(self.TitleLab.mas_right).offset(5);
        make.height.mas_equalTo(18);
        make.width.mas_equalTo(40);
    }];
    
    [self.timeRemainingLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.Pic).offset(15);
        make.bottom.equalTo(self.Pic.mas_bottom).offset(-30);
        make.height.mas_equalTo(20);
    }];
    
    [self.scr mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(0);
        make.top.equalTo(self.Pic.mas_bottom).offset(10);
        make.height.mas_equalTo(100);
        make.bottom.equalTo(self).offset(0);
    }];

}

- (BaseImageV *)Pic{
    if (!_Pic) {
        _Pic = [BaseImageV initCustom:CGRectZero contentMode:2];
        _Pic.backgroundColor = [UIColor grayColor];
        [_Pic setCornerRadiusWithRadius:6 isMasks:YES];
        [self addSubview:_Pic];
    }
    return _Pic;
}

- (BaseLab *)TitleLab{
    if (!_TitleLab) {
        _TitleLab = [BaseLab initCustomLab:@"特卖专场" color:[UIColor whiteColor] font:[UIFont fontWithName:@"PingFangSC-Semibold" size:20]];
        _TitleLab.backgroundColor = [UIColor clearColor];

        [self addSubview:_TitleLab];
    }
    return _TitleLab;
}

- (BaseLab *)TitleSubLab{
    if (!_TitleSubLab) {
        _TitleSubLab = [BaseLab initCustomLab:@"二手" color:[UIColor whiteColor] font:[UIFont fontWithName:@"PingFang-SC-Regular" size:15]];
        _TitleSubLab.textAlignment = 1;
        _TitleSubLab.textColor = [UIColor whiteColor];
        [_TitleLab setCornerRadiusWithRadius:2 isMasks:YES];
        [self addSubview:_TitleSubLab];
    }
    return _TitleSubLab;
}

- (BaseLab *)timeRemainingLab{
    if (!_timeRemainingLab) {
        _timeRemainingLab = [BaseLab initCustomLab:@"剩余时间" color:HexColor(0x333333) font:[UIFont fontWithName:@"PingFang-SC-Regular" size:15]];
        _timeRemainingLab.textColor = [UIColor whiteColor];
        _timeRemainingLab.backgroundColor = [UIColor clearColor];
        [self addSubview:_timeRemainingLab];
    }
    return _timeRemainingLab;
}

-(BaseScrollView *)scr{
    if (!_scr) {
        _scr = [[BaseScrollView alloc]init];
        _scr.backgroundColor = HexColor(0xeeeeee);
        _scr.bounces = NO;
        _scr.showsHorizontalScrollIndicator = NO;
        _scr.showsVerticalScrollIndicator = NO;
        _scr.bounces = NO; // 默认为YES 取消设置NO
        // 当bounces属性为NO时，以下两个属性设置无效
        _scr.alwaysBounceHorizontal = YES; // 水平方向弹簧效果
        _scr.alwaysBounceVertical = YES; // 垂直方向弹簧效果
        _scr.decelerationRate = 0.1; // 值域 0~1 值越小减速停止的时间越短
        _scr.pagingEnabled = YES;
        [self addSubview:_scr];
    }
    return _scr;
}
/**
 TitleLab
 TitleSubLab
 timeRemainingLab
 scr
 */


@end
